﻿using System;
using System.IO;
namespace yunio
{
    using yunio._req_http;
    using yunio.core;
    using yunio.helpers;

    public class YunioHttp
    {
        public static string UserAgent { get; set; } = YunioUserAgent.Create("YunIO");
        public static string GetText(string uri)
        {
            var text = HttpClient.GetText(uri);
            return text;
        }
        public static string GetText(string uri, YunioParam param)
        {
            helper.uri_add_param(ref uri, param);

            var text = HttpClient.GetText(uri);
            return text;
        }
        public static YunioJson GetJson(string uri)
        {
            var text = HttpClient.GetText(uri);
            return new YunioJson(text);
        }
        public static YunioJson GetJson(string uri, YunioParam param)
        {
            helper.uri_add_param(ref uri, param);

            var text = HttpClient.GetText(uri);
            return new YunioJson(text);
        }
        public static YunioJson PostJson(string uri, YunioJson json)
        {
            var text = HttpClient.PostJson(uri, json);
            return new YunioJson(text);
        }
        public static YunioJson PostJson(string uri, YunioParam param, YunioJson json)
        {
            helper.uri_add_param(ref uri, param);

            var text = HttpClient.PostJson(uri, json);
            return new YunioJson(text);
        }
        public static YunioJson PostJson(string uri, YunioParam param)
        {
            helper.uri_add_param(ref uri, param);

            var text = HttpClient.PostJson(uri);
            return new YunioJson(text);
        }
        public static YunioJson PostJson(string uri)
        {
            var text = HttpClient.PostJson(uri);
            return new YunioJson(text);
        }
        public static Stream PostDownload(string uri, YunioParam param, YunioJson json)
        {
            helper.uri_add_param(ref uri, param);

            var text = HttpClient.PostDownload(uri, json, out var filename);
            return text;
        }
        public static Stream Download(string uri, out string filename)
        {
            var text = HttpClient.Download(uri, out filename);
            return text;
        }
        public static void DownloadToFile(string uri, string path)
        {
            HttpClient.DownloadToFile(uri, path);
        }
        public static void Upload(string uri, MultiContent content)
        {
            HttpClient.JustPostUpload(uri, content);
        }
    }
}
